#pragma once

#include<string>
#include<iostream>
#include<fstream>
#include<vector>
#include"index.hpp"

namespace Util
{
    // 读写文件
    class FIleUtile
    {
        bool Read(std::ifstream &f, std::string *fulltext)
        {
            std::string line;
            while (getline(f, line))
            {
                *fulltext += line;
            }

            return true;
        }
    };

    // 切割字符串
    class StringUtil
    {
        // #define path "./date/raw_date/raw.txt"
        // static bool Split()
        // {
        //     std::ifstream In(path,std::ifstream::in);
        //     std::string s;
        //     std::vector<ns_index::DocInfo> Infos;
        //     while (getline(In,s))
        //     {
        //         ns_index::Split(s,&Infos);
        //     }
        // }
        // ststc bool Split(std::string s,std::vector<DocInfo>* Infos)
        // {
        //     DocInfo d;
        //     std::vector<std::string> vc;
        //     boost::split(vc,s,boost::is_any_of('\3'),boost::token_compress_on);
        //     if(vc.size()!=3)
        //     {
        //         return false;
        //     }

        //     d.title=vc[0];
        //     d.content=vc[1];
        //     d.url=vc[2];
        //     d.InfoId=Infos->size();
        //     Infos->push_back(d);

        //     return true;
        // }

private:        
    //字典
    // const char* const DICT_PATH = "./dict/jieba.dict.utf8";
    // const char* const HMM_PATH = "./dict/hmm_model.utf8";
    // const char* const USER_DICT_PATH = "./dict/user.dict.utf8";
    // const char* const IDF_PATH = "./dict/idf.utf8";
    // const char* const STOP_WORD_PATH = "./dict/stop_words.utf8";

public:
        static bool Cutstring(const std::string& s,std::vector<std::string>* words)
        {
            const char* const DICT_PATH = "./dict/jieba.dict.utf8";
            const char* const HMM_PATH = "./dict/hmm_model.utf8";
            const char* const USER_DICT_PATH = "./dict/user.dict.utf8";
            const char* const IDF_PATH = "./dict/idf.utf8";
            const char* const STOP_WORD_PATH = "./dict/stop_words.utf8";
            
            static cppjieba::Jieba jieba(DICT_PATH,
            HMM_PATH,
            USER_DICT_PATH,
            IDF_PATH,
            STOP_WORD_PATH);

            jieba.CutForSearch(s,*words);
            return true;
        }

    };

};